/**
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>

#include "name_mapping/name_mapping_manager.h"

using namespace testing::ext;

/**
 * @tc.name: name_mapping_manager_test_001
 * @tc.desc: Verify whether the names generated by the name generator are ordered.
 * @tc.type: FUNC
 * @tc.require:
 */
HWTEST(NameMappingTest, name_mapping_manager_test_001, TestSize.Level0)
{
    ark::guard::NameMappingManager manager;
    auto nameMapping = manager.GetNameMapping("xxx");
    ASSERT_NE(nameMapping, nullptr);

    ASSERT_EQ(nameMapping->GetName("x1"), "a");
    ASSERT_EQ(nameMapping->GetName("x2"), "b");
    ASSERT_EQ(nameMapping->GetName("x1"), "a");
    ASSERT_EQ(nameMapping->GetName("x3"), "c");
}

/**
 * @tc.name: name_mapping_manager_test_002
 * @tc.desc: Verify whether the names in the whitelist are retained in the name generator.
 * @tc.type: FUNC
 * @tc.require:
 */
HWTEST(NameMappingTest, name_mapping_manager_test_002, TestSize.Level0)
{
    ark::guard::NameMappingManager manager;
    auto nameMapping = manager.GetNameMapping("xxx");
    ASSERT_NE(nameMapping, nullptr);

    const auto name = "_$init$_";
    ASSERT_EQ(nameMapping->GetName(name), name);
}
